<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test01</title>
</head>
<body>
<script type="text/javascript">
    // function Person(name, age) {
    //     this.name = name;
    //     this.age = age;
    // }
    //
    // Person.prototype.sayName = function () {
    //     console.log(this.name);
    // };

    class Person {
        static foo = 'bar';

        constructor(name, age) {
            this.name = name;
            this.age = age;
            // this.sayName = this.sayName.bind(this);
        }

        // sayName() {
        //     console.log(this.name);
        // }

        sayName = () => console.log(this.name);

        _priMethod() {
            console.log("Private Method");
        }

        static sayFoo() {
            // console.log(Person.foo);
            console.log(this.foo);
        }
    }

    Object.assign(Person.prototype, {
        sayAge() {
            console.log(this.age);
        },

        sayMe() {
            console.log(this.name + "," + this.age);
        }
    });

    let p01 = new Person("zhangsan", 18);
    p01.sayName();
    p01.sayAge();
    p01.sayMe();

    console.log(typeof Person);

    console.dir(p01);

    console.log(Person.prototype.constructor === Person);
    console.log(p01.constructor === Person);

    console.log(Person.name);

    console.log(Person.foo);
    console.log(p01.foo);

    Person.sayFoo();
    // p01.sayFoo();

    p01._priMethod();

    p01.sayName.call({
        name: 'lisi'
    });

    const {sayName} = p01;

    sayName();


</script>
</body>
</html>